package net.mysoft.budgetsoft.system.domain;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.alibaba.fastjson.annotation.JSONField;

import flexjson.JSON;

/**
 * 菜单
 * @author kangrui
 *
 */
@Table(name="t_menu")
@Entity
public class TMenu extends BaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 605373182358244431L;
	
	@Column(length=20)
	private String code;
	@Column(length=30)
	private String url;			//链接地址
	@ManyToOne
	private TMenu root;			//根菜单
	@ManyToOne
	private TMenu parent;		//父菜单
	@OneToMany(mappedBy="parent", fetch=FetchType.LAZY)
	private List<TMenu> sons;	//子菜单
	@OneToMany(mappedBy="root", fetch=FetchType.LAZY)
	private List<TMenu> menus;	//子菜单
	@ManyToMany(mappedBy="menus")
	private List<TRole> roles;	//可以看到该菜单的角色
	
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public TMenu getParent() {
		return parent;
	}
	public void setParent(TMenu parent) {
		this.parent = parent;
	}
	public List<TMenu> getSons() {
		return sons;
	}
	public void setSons(List<TMenu> sons) {
		this.sons = sons;
	}
	public List<TRole> getRoles() {
		return roles;
	}
	public void setRoles(List<TRole> roles) {
		this.roles = roles;
	}
	public TMenu getRoot() {
		return root;
	}
	public void setRoot(TMenu root) {
		this.root = root;
	}
	public List<TMenu> getMenus() {
		return menus;
	}
	public void setMenus(List<TMenu> menus) {
		this.menus = menus;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	
	public String toString() {
		return super.getName();
	}

}
